home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Bus / T-Z / VCR+(app+src) Folder / Sources / Mixup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-14  |  603 b   |  47 lines  |  [TEXT/KAHL]

  1. #include "VCRplus.h"
  2.  
  3. /* function that performs initial scrambling */
  4. long     mixup(long x, long y)
  5. {
  6.     long     i, j, k, sum;
  7.  
  8.     long     a[12], b[12], out[12] ;
  9.  
  10.     /* get the digits of x into a[] */
  11.     j = x ;
  12.     for(i=0; i<9; i++)
  13.     {
  14.         k = j % 10;
  15.         a[i] = k;
  16.         j = (j - k) / 10 ;
  17.     }
  18.  
  19.     /* get the digits of y into b[] */
  20.     j = y ;
  21.     for(i=0; i<9; i++)
  22.     {
  23.         k = j % 10;
  24.         b[i] = k;
  25.         j = (j - k) / 10 ;
  26.         out[i] = 0;
  27.     }
  28.  
  29.  
  30.     for(i=0; i<=8; i++)
  31.     {
  32.         for(j=0; j<=8; j++)
  33.         {
  34.             out[i+j] += (b[j] * a[i]) ;
  35.         }
  36.     }
  37.  
  38.     j = 1;
  39.     sum = 0;
  40.     for(i=0; i<=8; i++)
  41.     {
  42.         sum += j * (out[i] % 10);
  43.         j = j * 10 ;
  44.     }
  45.     return( sum ) ;
  46. }
  47.